package com.testing.sunnycommon.aspect;

import com.testing.sunnycommon.service.SunnyProjectService;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Classname CountProjectAspect
 * @Description 类型说明
 * @Date 2023/5/31 21:06
 * @Created by 特斯汀Roy
 */
@Aspect
@Component
public class CountProjectAspect {
    @Autowired
    SunnyProjectService sunnyProjectService;

    @Pointcut("execution(public * com.testing.sunnycommon.controller.SunnyCaseController.addCase(..))" +
            "||execution(public * com.testing.sunnycommon.controller.SunnyCaseController.deleteCases(..))")
    public void countProject() {
    }

    @After("countProject()")
    public void countProjectCase() {
        sunnyProjectService.list().forEach(project -> sunnyProjectService.updateSunnyProject(project));
    }


}
